package demo;

public class Demo3 {
    public static void main(String[] args) throws InterruptedException {
        Thread mainThread=Thread.currentThread();
        Thread t=new Thread(()->{
            int i=3;
           while(i>=0){
               System.out.println("hello thread");
               /*try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }*/
               i--;
               try {
                   //t等待main
                   mainThread.join();
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
           }
        });
        System.out.println(t.getState());
        t.start();
        Thread.sleep(500);
        System.out.println(t.getState());
        //main等待t
        t.join();
        System.out.println(t.getState());

    }
}
